package day05;

/**
 * @author yzh
 * @desc TODO
 * @date 2025/4/14
 */
public class MaxElementIndex {
    public static void main(String[] args) {
        int[] arr= {10,20,30,40,50,60};
        int index = maxElementIndex(arr);
        System.out.println("最大值索引为"+index);
    }

    public static int maxElementIndex(int[] arr) {
        int max = arr[0];
        int index = 0; // 记录最大值索引
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] > max) {
                max = arr[i];
                index = i;
            }
        }
        return index;
    }
}
